﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Money.Plugins.Import.TescoImportV2
{
    public partial class ConfigurationForm : Form
    {
        private Configuration _configuration;

        public ConfigurationForm(Configuration config)
        {
            InitializeComponent();

            _configuration = config;

            _parser.Text = _configuration.MatchString;
            _fieldCount.Text = _configuration.FieldCount.ToString();
            _applyNameTidy.Checked = _configuration.ApplyNameTidy;
        }

        private void btnAccept_Click(object sender, EventArgs e)
        {
            // TODO update all of the changed fields into the configuration settings
            _configuration.FieldCount = Convert.ToInt16(_fieldCount.Text);
            _configuration.MatchString = _parser.Text;
            _configuration.ApplyNameTidy = _applyNameTidy.Checked;
            
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
